const li=document.createElement('li')
const ul=document.querySelector('.remarks ul')
const anniu=document.querySelector('.anniu')
/* const text=document.querySelector('') */
const tx=document.querySelector('#tx')

function publish(){
  console.log(tx.value)
   if(tx.value===''){return}

  const li=document.createElement('li')
  li.innerHTML=`
  
      <div class="avatar"></div>
      <div class="contents">
       
        <div class="identification">
          
          <p class="name">小米米</p>
          <p class="IP">IP:湖南</p>
          <p class="usertime">2024/11/06 22:20:15</p>
        </div>
        <div class="pltext">
          <p>${tx.value}</p>
         
        </div>
         <div class="plappraise">
              <p class="dz">赞[<span>0</span>]</p>
              <p>踩[<span>0</span>]</p>
              <p>回复[<span>0</span>]</p>
              <p>分享</p>
          </div>
          `
          ul.appendChild(li)
          tx.value=''
}
tx.addEventListener('keyup',function(e){
  if(e.key==='Enter'){
    publish()
  }
})
clock()
anniu.addEventListener('click',publish)
function clock(){
const dainz=document.querySelector('.plappraise p:nth-child(1)')
const cai=document.querySelector('.plappraise p:nth-child(2)')

const dainzwz=document.querySelector('.plappraise p:nth-child(1) span')
const caiwz=document.querySelector('.plappraise p:nth-child(2) span')
let statedz=false

const dz=document.querySelectorAll('.dz')
for(let i=0;i<dz.length;i++){
  dz[i].addEventListener('click',function(){
    console.log('sss')
  })
}
dainz.addEventListener('click',function(){
  console.log('111')
  if(statedz===false){
    dainzwz.innerHTML=+(dainzwz.innerHTML)+1
    this.classList.add('dianz')
    statedz=true
  }else{
    this.classList.remove('dianz')
    dainzwz.innerHTML=+(dainzwz.innerHTML)-1
    statedz=false
  }
})

let statec=false
cai.addEventListener('click',function(){
  if(statec===false){
    caiwz.innerHTML=+(caiwz.innerHTML)+1
    this.classList.add('cai')
    statec=true
  }else{
    this.classList.remove('cai')
    caiwz.innerHTML=+(caiwz.innerHTML)-1
    statec=false
  }
})
} 

console.log(navigator.userAgent)
function isMobile() {  
  // 这些字符串是常见的移动设备的User Agent片段  
  var mobileAgents = [  
    "Android", "webOS", "iPhone", "iPad", "iPod", "BlackBerry", "IEMobile", "Opera Mini"  
  ];  

  var userAgent = navigator.userAgent || navigator.vendor || window.opera;  

  // 检查User Agent是否包含上述任何一个移动设备的片段  
  for (var i = 0; i < mobileAgents.length; i++) {  
      if (userAgent.indexOf(mobileAgents[i]) > -1) {  
          return true; // 如果是移动设备，返回true  
      }  
  }  

  return false; // 如果不是移动设备，返回false  
}  

// 使用函数  
if (isMobile()) {  
  console.log("这是移动设备"); 

} else {  
  console.log("这是PC或其他非移动设备");  
  
}